home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / hexa.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  3KB  |  127 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12.  
  13. static int charbank;
  14. static int flipx,flipy;
  15.  
  16.  
  17. void hexa_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  18. {
  19.     int i;
  20.  
  21.  
  22.     for (i = 0;i < Machine->drv->total_colors;i++)
  23.     {
  24.         int bit0,bit1,bit2,bit3;
  25.  
  26.  
  27.         bit0 = (color_prom[0] >> 0) & 0x01;
  28.         bit1 = (color_prom[0] >> 1) & 0x01;
  29.         bit2 = (color_prom[0] >> 2) & 0x01;
  30.         bit3 = (color_prom[0] >> 3) & 0x01;
  31.         *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  32.         bit0 = (color_prom[Machine->drv->total_colors] >> 0) & 0x01;
  33.         bit1 = (color_prom[Machine->drv->total_colors] >> 1) & 0x01;
  34.         bit2 = (color_prom[Machine->drv->total_colors] >> 2) & 0x01;
  35.         bit3 = (color_prom[Machine->drv->total_colors] >> 3) & 0x01;
  36.         *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  37.         bit0 = (color_prom[2*Machine->drv->total_colors] >> 0) & 0x01;
  38.         bit1 = (color_prom[2*Machine->drv->total_colors] >> 1) & 0x01;
  39.         bit2 = (color_prom[2*Machine->drv->total_colors] >> 2) & 0x01;
  40.         bit3 = (color_prom[2*Machine->drv->total_colors] >> 3) & 0x01;
  41.         *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  42.  
  43.         color_prom++;
  44.     }
  45. }
  46.  
  47.  
  48.  
  49. WRITE_HANDLER( hexa_d008_w )
  50. {
  51.     int bankaddress;
  52.     unsigned char *RAM = memory_region(REGION_CPU1);
  53.  
  54.  
  55.     /* bit 0 = flipx (or y?) */
  56.     if (flipx != (data & 0x01))
  57.     {
  58.         flipx = data & 0x01;
  59.         memset(dirtybuffer,1,videoram_size);
  60.     }
  61.  
  62.     /* bit 1 = flipy (or x?) */
  63.     if (flipy != (data & 0x02))
  64.     {
  65.         flipy = data & 0x02;
  66.         memset(dirtybuffer,1,videoram_size);
  67.     }
  68.  
  69.     /* bit 2 - 3 unknown */
  70.  
  71.     /* bit 4 could be the ROM bank selector for 8000-bfff (not sure) */
  72.     bankaddress = 0x10000 + ((data & 0x10) >> 4) * 0x4000;
  73.     cpu_setbank(1,&RAM[bankaddress]);
  74.  
  75.     /* bit 5 = char bank */
  76.     if (charbank != ((data & 0x20) >> 5))
  77.     {
  78.         charbank = (data & 0x20) >> 5;
  79.         memset(dirtybuffer,1,videoram_size);
  80.     }
  81.  
  82.     /* bit 6 - 7 unknown */
  83. }
  84.  
  85.  
  86.  
  87. /***************************************************************************
  88.  
  89.   Draw the game screen in the given osd_bitmap.
  90.   Do NOT call osd_update_display() from this function, it will be called by
  91.   the main emulation engine.
  92.  
  93. ***************************************************************************/
  94. void hexa_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  95. {
  96.     int offs;
  97.  
  98.  
  99.     /* for every character in the Video RAM, check if it has been modified */
  100.     /* since last time and update it accordingly. */
  101.     for (offs = videoram_size - 2;offs >= 0;offs -= 2)
  102.     {
  103.         if (dirtybuffer[offs] || dirtybuffer[offs + 1])
  104.         {
  105.             int sx,sy;
  106.  
  107.  
  108.             dirtybuffer[offs] = 0;
  109.             dirtybuffer[offs + 1] = 0;
  110.  
  111.             sx = (offs/2) % 32;
  112.             sy = (offs/2) / 32;
  113.             if (flipx) sx = 31 - sx;
  114.             if (flipy) sy = 31 - sy;
  115.  
  116.             drawgfx(tmpbitmap,Machine->gfx[0],
  117.                     videoram[offs + 1] + ((videoram[offs] & 0x07) << 8) + (charbank << 11),
  118.                     (videoram[offs] & 0xf8) >> 3,
  119.                     flipx,flipy,
  120.                     8*sx,8*sy,
  121.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  122.         }
  123.     }
  124.  
  125.     copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  126. }
  127.